import argparse
import platform
import uuid

from model.WebsocketClientVO import WebsocketClientVO


class CommandParser(object):

    def __init__(self):
        self.__isWindows = platform.system().lower() == 'windows'
        self.__parser = argparse.ArgumentParser(
            prog='路由器客户端',
            description='',
            epilog='')
        dHost = 'ws://localhost:8080/router/'
        dToken = 'banlv_router_token'
        info = str(uuid.getnode())
        clashHost = "http://172.16.0.1:9090"
        clashConfigPath = "/etc/clash/config.yaml"
        clashToken = '123456'
        self.__parser.add_argument('-o', '--host', type=str, default=dHost, help='websocket 服务器地址 默认值:' + dHost)
        self.__parser.add_argument('-t', '--token', type=str, default=dToken, help='服务器效验token 默认值: ' + dToken)
        self.__parser.add_argument('-i', '--info', type=str, default=info, help='设备编号 默认值: ' + info)
        self.__parser.add_argument('-c', '--clash', type=str, default=clashHost, help='clash host 默认值: ' + clashHost)
        self.__parser.add_argument('-ct', '--clash-token', type=str, default=clashToken, help='clash token 默认值: ' + clashToken)
        self.__parser.add_argument('-cp', '--clash-config-path', type=str, default=clashConfigPath, help='clash config file path 默认值: ' + clashConfigPath)
        self.__parser.add_argument('-d', '--dev', type=str, default='false', help='开发模式默认值: true')



    def parseArgs(self) -> WebsocketClientVO:
        args = self.__parser.parse_args()
        return WebsocketClientVO(args.host, args.token, args.info, args.clash, args.clash_config_path, args.clash_token, args.dev == 'true')
